blob: b6a33f579b4009d1497fdc104c07633793d53f01 [file] [log] [blame]
Nicolás Peña92d1f6c2019-02-13 20:05:531<!DOCTYPE HTML>
2<meta charset=utf-8>
Nicolás Peña Morenoc13852e2019-07-08 18:51:043<title>Layout Instability entries are not available via the performance timeline</title>
Nicolás Peña92d1f6c2019-02-13 20:05:534<body>
5<style>
6#myDiv { position: relative; width: 300px; height: 100px; }
7</style>
8<div id='myDiv'></div>
9<script src="/resources/testharness.js"></script>
10<script src="/resources/testharnessreport.js"></script>
Nicolás Peña Moreno11f1a592019-12-27 22:36:5711<script src="resources/util.js"></script>
Nicolás Peña92d1f6c2019-02-13 20:05:5312<script>
Nicolás Peña Moreno11f1a592019-12-27 22:36:5713async_test(async function(t) {
14 assert_precondition(window.LayoutShift, 'LayoutShift entries are not supported');
15 // Wait for the initial render to complete.
16 await waitForAnimationFrames(2);
Nicolás Peña Morenoc13852e2019-07-08 18:51:0417
Nicolás Peña Moreno11f1a592019-12-27 22:36:5718 const startTime = performance.now();
19 new PerformanceObserver(t.step_func_done(list => {
20 const endTime = performance.now();
21 assert_equals(list.getEntries().length, 1);
22 const entry = list.getEntries()[0];
23 assert_equals(entry.entryType, "layout-shift");
24 assert_equals(entry.name, "");
25 assert_greater_than_equal(entry.startTime, startTime);
26 assert_less_than_equal(entry.startTime, endTime);
27 assert_equals(entry.duration, 0.0);
28 // The layout shift value should be:
29 // 300 * (100 + 60) * (60 / maxDimension) / viewport size.
30 assert_equals(entry.value, computeExpectedScore(300 * (100 + 60), 60));
31
32 // The entry should not be available via getEntries* methods.
33 assert_equals(performance.getEntriesByType('layout-shift').length, 0, 'getEntriesByType should have no layout-shift entries');
34 assert_equals(performance.getEntriesByName('', 'layout-shift').length, 0, 'getEntriesByName should have no layout-shift entries');
35 assert_equals(performance.getEntries().filter(e => e.entryType === 'layout-shift').length, 0, 'getEntries should have no layout-shift entries');
36 })).observe({type: 'layout-shift'});
37 // Modify the position of the div.
38 document.getElementById('myDiv').style = "top: 60px";
39}, 'Layout shift before onload is not buffered into the performance timeline.');
Nicolás Peña92d1f6c2019-02-13 20:05:5340</script>
41
42</body>